```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java线程编程指南 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #282a36;
            border-radius: 8px;
            position: relative;
        }
        .copy-btn {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background: rgba(255,255,255,0.1);
            border: none;
            color: #f8f8f2;
            padding: 0.25rem 0.5rem;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .copy-btn:hover {
            background: rgba(255,255,255,0.2);
        }
        .state-card {
            transition: all 0.3s ease;
            border-left: 4px solid;
        }
        .state-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .fade-in {
            animation: fadeIn 0.5s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 animate-pulse">Java线程编程完全指南</h1>
            <p class="text-xl md:text-2xl mb-8 font-light opacity-90">掌握并发编程的基础核心概念与最佳实践</p>
            <div class="flex justify-center space-x-4">
                <a href="#creation" class="px-6 py-3 bg-white text-purple-700 rounded-full font-medium hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-code mr-2"></i>线程创建
                </a>
                <a href="#lifecycle" class="px-6 py-3 bg-transparent border-2 border-white rounded-full font-medium hover:bg-white hover:text-purple-700 transition duration-300">
                    <i class="fas fa-project-diagram mr-2"></i>生命周期
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-4xl py-12 px-4 md:px-0">
        <!-- Intro Section -->
        <section class="mb-16 fade-in">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-microchip text-purple-600 mr-3"></i>
                    线程基础概念
                </h2>
                <p class="text-lg text-gray-700 leading-relaxed">
                    线程是并发编程中不可或缺的基础，Java通过<code class="bg-gray-100 px-2 py-1 rounded">Thread</code>类提供了多种方式来创建和管理线程。理解线程的创建、管理和生命周期对于提升并发编程能力至关重要。
                </p>
            </div>
        </section>

        <!-- Thread Creation Section -->
        <section id="creation" class="mb-16 fade-in">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b-2 border-purple-200 pb-2 flex items-center">
                <i class="fas fa-plus-circle text-purple-600 mr-3"></i>
                线程的创建方式
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Extending Thread -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition duration-300">
                    <div class="bg-purple-600 text-white px-6 py-4">
                        <h3 class="text-xl font-bold flex items-center">
                            <i class="fas fa-code-branch mr-2"></i>
                            继承Thread类
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-gray-700 mb-4">通过继承<code>Thread</code>类并重写<code>run()</code>方法来创建线程。</p>
                        <div class="code-block mb-4">
                            <button class="copy-btn" onclick="copyCode(this)">
                                <i class="fas fa-copy"></i>
                            </button>
                            <pre class="text-gray-300 p-4 overflow-x-auto"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("Thread is running.");
    }

    public static void main(String[] args) {
        MyThread thread = new MyThread();
        thread.start();  // 启动线程
    }
}</code></pre>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span><code>run()</code>方法：线程执行的具体任务</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span><code>start()</code>方法：使线程进入"就绪"状态</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <!-- Implementing Runnable -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden hover:shadow-lg transition duration-300">
                    <div class="bg-indigo-600 text-white px-6 py-4">
                        <h3 class="text-xl font-bold flex items-center">
                            <i class="fas fa-project-diagram mr-2"></i>
                            实现Runnable接口
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-gray-700 mb-4">通过实现<code>Runnable</code>接口并将其传递给<code>Thread</code>对象来创建线程。</p>
                        <div class="code-block mb-4">
                            <button class="copy-btn" onclick="copyCode(this)">
                                <i class="fas fa-copy"></i>
                            </button>
                            <pre class="text-gray-300 p-4 overflow-x-auto"><code>public class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("Runnable thread is running.");
    }

    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread thread = new Thread(myRunnable);
        thread.start();  // 启动线程
    }
}</code></pre>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span><code>Runnable</code>只定义<code>run()</code>方法</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>更灵活，推荐使用</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Lifecycle Section -->
        <section id="lifecycle" class="mb-16 fade-in">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b-2 border-purple-200 pb-2 flex items-center">
                <i class="fas fa-life-ring text-purple-600 mr-3"></i>
                线程生命周期
            </h2>
            
            <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                <h3 class="text-2xl font-bold mb-6 text-gray-800">线程状态转换</h3>
                <div class="mermaid mb-6">
                    stateDiagram-v2
                    [*] --> New
                    New --> Runnable: start()
                    Runnable --> Running: JVM调度
                    Running --> Terminated: 执行完毕
                    Running --> Blocked: 等待锁
                    Blocked --> Runnable: 获取锁
                    Running --> Waiting: wait()
                    Waiting --> Runnable: notify()
                    Running --> TimedWaiting: sleep()
                    TimedWaiting --> Runnable: 时间到
                </div>
                <p class="text-gray-700">线程在生命周期中会经历多个状态，Java线程的状态由<code>Thread.State</code>枚举表示。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-6">
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-blue-500">
                    <h4 class="font-bold text-lg mb-3 text-blue-600">新建 (New)</h4>
                    <p class="text-gray-700">线程被创建，但未启动。</p>
                </div>
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-green-500">
                    <h4 class="font-bold text-lg mb-3 text-green-600">就绪 (Runnable)</h4>
                    <p class="text-gray-700">线程已被启动，等待CPU调度。</p>
                </div>
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-purple-500">
                    <h4 class="font-bold text-lg mb-3 text-purple-600">运行 (Running)</h4>
                    <p class="text-gray-700">线程正在执行。</p>
                </div>
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-yellow-500">
                    <h4 class="font-bold text-lg mb-3 text-yellow-600">阻塞 (Blocked)</h4>
                    <p class="text-gray-700">线程因等待锁而被阻塞。</p>
                </div>
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-red-500">
                    <h4 class="font-bold text-lg mb-3 text-red-600">等待 (Waiting)</h4>
                    <p class="text-gray-700">线程等待某个条件，进入等待状态。</p>
                </div>
                <div class="state-card bg-white rounded-lg shadow-md p-6 border-l-4 border-indigo-500">
                    <h4 class="font-bold text-lg mb-3 text-indigo-600">定时等待 (Timed Waiting)</h4>
                    <p class="text-gray-700">线程在指定时间内等待。</p>
                </div>
            </div>
        </section>

        <!-- Methods Section -->
        <section class="mb-16 fade-in">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-b-2 border-purple-200 pb-2 flex items-center">
                <i class="fas fa-cogs text-purple-600 mr-3"></i>
                核心方法解析
            </h2>
            
            <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                <h3 class="text-2xl font-bold mb-4 text-gray-800 flex items-center">
                    <i class="fas fa-play-circle text-blue-500 mr-2"></i>
                    start() vs run()
                </h3>
                <div class="grid md:grid-cols-2 gap-6 mb-6">
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-blue-600">start()</h4>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-blue-500 mt-1 mr-2"></i>
                                <span>启动新线程，JVM调用run()方法</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-blue-500 mt-1 mr-2"></i>
                                <span>只能调用一次</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-blue-500 mt-1 mr-2"></i>
                                <span>线程进入就绪状态</span>
                            </li>
                        </ul>
                    </div>
                    <div class="bg-green-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-green-600">run()</h4>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-green-500 mt-1 mr-2"></i>
                                <span>定义线程执行的任务</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-green-500 mt-1 mr-2"></i>
                                <span>直接调用会在当前线程执行</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-angle-right text-green-500 mt-1 mr-2"></i>
                                <span>可以被多次调用（但不推荐）</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-lg p-8">
                <h3 class="text-2xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-power-off text-red-500 mr-2"></i>
                    线程中断与停止
                </h3>
                <div class="code-block mb-6">
                    <button class="copy-btn" onclick="copyCode(this)">
                        <i class="fas fa-copy"></i>
                    </button>
                    <pre class="text-gray-300 p-4 overflow-x-auto"><code>public class MyThread extends Thread {
    @Override
    public void run() {
        try {
            sleep(5000);  // 模拟阻塞
        } catch (InterruptedException e) {
            System.out.println("Thread interrupted.");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread thread = new MyThread();
        thread.start();  // 启动线程
        Thread.sleep(1000);  // 主线程睡眠1秒
        thread.interrupt();  // 中断线程
    }
}</code></pre>
                </div>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-yellow-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-yellow-600">interrupt()</h4>
                        <p class="text-gray-700">请求中断线程，如果线程正在阻塞状态（如<code>sleep()</code>, <code>wait()</code>等），会抛出<code>InterruptedException</code>。</p>
                    </div>
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-purple-600">线程死亡</h4>
                        <p class="text-gray-700">线程执行完<code>run()</code>方法后进入死亡状态，所有资源被回收，无法再次启动。</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto px-4 text-center">
            <h3 class="text-xl font-bold mb-2">技术小馆</h3>
            <p class="mb-4">分享编程知识与技术干货</p>
            <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300 inline-flex items-center">
                <i class="fas fa-external-link-alt mr-1"></i>
                访问我们的语雀主页
            </a>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Copy code button functionality
        function copyCode(button) {
            const codeBlock = button.parentElement.querySelector('code');
            const text = codeBlock.textContent;
            
            navigator.clipboard.writeText(text).then(() => {
                button.innerHTML = '<i class="fas fa-check"></i>';
                setTimeout(() => {
                    button.innerHTML = '<i class="fas fa-copy"></i>';
                }, 2000);
            });
        }

        // Add fade-in animation when scrolling
        document.addEventListener('DOMContentLoaded', () => {
            const fadeElements = document.querySelectorAll('.fade-in');
            
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.style.opacity = 1;
                        entry.target.style.transform = 'translateY(0)';
                    }
                });
            }, {
                threshold: 0.1
            });

            fadeElements.forEach(el => {
                el.style.opacity = 0;
                el.style.transform = 'translateY(20px)';
                el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
                observer.observe(el);
            });
        });
    </script>
</body>
</html>
```